<%@ page language="java" %>

<%@ page import="java.util.*,
                 java.net.*,
                 java.lang.*,
                 com.broadvision.ssp.client.SspInstance,
                 com.broadvision.web.util.ViewDynaBean,
		 org.apache.struts.validator.DynaValidatorForm,
                 org.apache.commons.beanutils.PropertyUtils,
                 com.broadvision.process.tools.action.process.ProcessList"
%>

<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<script language="JavaScript">
 function doWebflowAction(theForm,cntOID,version,cntAction){
   var theURL="/cm/launchVSWebflow.do";
   var theParam="?guid="+cntOID+"&version="+version+
             "&launchAction="+cntAction+"&exitURL="+"/cm/closeWindow.do";
   var url ='<html-el:rewrite page="'+theURL+'" />'+theParam;
   var qualifier = window.open(url, "ContentServiceLaunchProcess",
                               "directories=no,height=500,width=650,left=50,top=50,resizable=yes,scrollbars=yes,location=yes,menubar=yes,status=yes,toolbar=yes");

  if (qualifier != null){
    if (qualifier.opener == null)
        qualifier.opener = self;
    qualifier.focus();
  }

 }
 function doAction(theForm,cntOID,version,cntAction){
   var theURL="/cm/cmProcessMapping.do";
   var theParam="?contentOID="+cntOID+"&version="+version+"&contentAction="+cntAction;
   var url ='<html-el:rewrite page="'+theURL+'" />'+theParam;
   var qualifier = window.open(url, "ContentServiceLaunchProcess",
                              "directories=no,height=500,width=650,left=50,top=50,resizable=yes,scrollbars=yes,location=yes,menubar=yes,status=yes,toolbar=yes");

   if (qualifier != null){
     if (qualifier.opener == null)
         qualifier.opener = self;
    qualifier.focus();
  }

 }
   function doAttachment(theForm,value){
     theForm.filePath.value=value;
     var theURL="/cm/contentAttachDetail.do";
     theForm.action='<html:rewrite page="'+theURL+'" />';
     theForm.submit();
     return true;
   }
</script>

<jsp:useBean id="csSearchResultView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 
<bean:size id="resultSize" name="csSearchResultView" property="resultList"/>

<% 
   String ctxPath = request.getContextPath(); 

   ViewDynaBean view = (ViewDynaBean) request.getAttribute("csSearchResultView"); 
   Integer totalCount = (Integer) PropertyUtils.getSimpleProperty(view, "totalCount");  
%>

<script language="javascript" src="<%=request.getContextPath()%>/mt/js/date.js"></script>
<script language="javascript" src="<%=request.getContextPath()%>/bp/js/user_popup_funcs.js"></script>

<script language="javascript">

 function doGoCnt(formName) {
  var thisForm = document.forms[formName];
  if (thisForm != null) {
      thisForm.pageNum.value = 1;
      thisForm.submit();
  }
  return false;
}


function selectOverdue(myform) {
  with (myform) {
    includeDueDateEnd.checked=true;
    includeDueDateStart.checked=false;
    if ( sspInstanceStatus == null ) 
        return true;
    if ( sspInstanceStatus.length == null ) {
        sspInstanceStatus.checked = false;
        return true;
    }
    for (i = 0; i < sspInstanceStatus.length; i++)
        sspInstanceStatus[i].checked = false;
    sspInstanceStatus[0].checked = true;
    sspInstanceStatus[1].checked = true;
    var now = new Date();
    var year = now.getYear();
    if (year < 1900) year += 1900;
    elements["dueDateEnd.month"].value=now.getMonth();
    elements["dueDateEnd.day"].value=now.getDate();
    elements["dueDateEnd.year"].value=year;
    return true;
  }
}

 
function acl(myform) {
  with (myform) {
   if (procMgrID.options.selectedIndex==procMgrID.options.length-1)
    procInstMgrID.options[0].selected = true;
  }
}
 
function acl2(myform) {
  with (myform) {
   if (procInstMgrID.options.selectedIndex==procInstMgrID.options.length-1)
    procMgrID.options[0].selected = true;
   }
}
 
function validateForm(myform, formname) {
  if (myform.includeCreateDateStart.checked) {
    var date = getDateOnly(formname, "createDateStart");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.createDateStart"/>');
      return false;
    }
  }

  if (myform.includeCreateDateEnd.checked) {
    var date = getDateOnly(formname, "createDateEnd");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.createDateEnd"/>');
      return false;
    }
  }

  if (myform.includeModDateStart.checked) {
    var date = getDateOnly(formname, "modDateStart");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.modDateStart"/>');
      return false;
    }
  }

  if (myform.includeModDateEnd.checked) {
    var date = getDateOnly(formname, "modDateEnd");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.modDateEnd"/>');
      return false;
    }
  }

  if (myform.includeLaunchDateStart.checked) {
    var date = getDateOnly(formname, "launchDateStart");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.launchDateStart"/>');
      return false;
    }
  }

  if (myform.includeLaunchDateEnd.checked) {
    var date = getDateOnly(formname, "launchDateEnd");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.launchDateEnd"/>');
      return false;
    }
  }

  if (myform.includeDueDateStart.checked) {
    var date = getDateOnly(formname, "dueDateStart");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.dueDateStart"/>');
      return false;
    }
  }

  if (myform.includeDueDateEnd.checked) {
    var date = getDateOnly(formname, "dueDateEnd");
    if (null == date) {
      alert('<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.error.dueDateEnd"/>');
      return false;
    }
  }
  
  return true;
}

function setUserAlias(formName, fieldName, fieldValue) {
  // this page does not have any hidden fields that rely on the popup,
  // we do not need a refresh url.
  var refreshUrl = null;
  setFieldValue(refreshUrl, formName, fieldName, fieldValue);
}

function gotoPage(formName, pageNum) {
  var thisForm = document.forms[formName];
  if (thisForm != null) {
    thisForm.pageNum.value = pageNum;
    thisForm.submit();
  }
}
  
function isAllDigits(argvalue) {
   argvalue = argvalue.toString();
   var validChars = "0123456789";
   var startFrom = 0;

   if (argvalue.length==0)
     return false;
   for (var n = startFrom; n < argvalue.length; n++) {
       if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
   }
   return true;
}

function onSubmit(myform, formname) {
  if (!validateForm(myform, formname)) return false;
  if (myform.contentName.value.length == 0 &&
      myform.attributes1a.value.length ==0 &&
      myform.attributes2a.value.length ==0 &&
      myform.attributes3a.value.length ==0 &&
      myform.attributes4a.value.length ==0 &&
      !myform.includeCreateDateStart.checked &&
      !myform.includeCreateDateEnd.checked &&
      !myform.includeModDateStart.checked &&
      !myform.includeModDateEnd.checked &&
      myform.procModelName.value.length == 0 &&
      myform.procInstanceName.value.length == 0 &&
      !myform.includeLaunchDateStart.checked &&
      !myform.includeLaunchDateEnd.checked &&
      !myform.includeDueDateStart.checked &&
      !myform.includeDueDateEnd.checked &&
      myform.procMgrID.value.length == 0 &&
      myform.procInstMgrID.value.length == 0 &&
      myform.procInstParticipantID.value.length == 0 &&
      myform.procInitiatorID.value.length == 0 &&
      myform.sspInstanceStatus.length ==0 )
  {
     alert('<bean:message bundle="cm.messages" key="cm.content.search.nocriteria"/>');
     return false;
   }
  if ( (myform.attributes1a.value == 'VersionNumber' && 
        !isAllDigits(myform.attributes1c.value)) || 
       (myform.attributes2a.value == 'VersionNumber' && 
        !isAllDigits(myform.attributes2c.value)) || 
       (myform.attributes3a.value == 'VersionNumber' && 
        !isAllDigits(myform.attributes3c.value)) || 
       (myform.attributes4a.value == 'VersionNumber' && 
        !isAllDigits(myform.attributes4c.value)) ) {
     alert('<bean:message bundle="cm.messages" key="cm.content.version.invalidValue"/>');
     return false;
  }
  myform.submit();
  return true;
}
function doRefresh() {
  return onSubmit(document.forms["cmCSSearchForm"],"cmCSSearchForm");
}

function doUncheckout(theForm, contentOid) {
  theForm.action = '<html-el:rewrite page="/cm/uncheckOut.do"/>';
  theForm.contentOid.value = contentOid;
  theForm.submit();
  return false;
}  

</script>

<jsp:useBean id="cmContentAdmin" scope="session" type="java.lang.Boolean"/>

<html:form action="/cm/cmCSSearch.do?action=search">
<html:hidden property="pageNum" value="1" />
<html:hidden property="filePath" />
<input type="hidden" name="contentOid"/>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle="cm.messages" key="cm.content.advSearch"/>">
  <tr> 
  <td valign="top" width="100%">
		  
  <div class="pageTitle"><bean:message bundle="cm.messages" key="cm.content.advSearch"/></div>

<%@include file="/mc/common/pagetab.jsp" %>
  <div class="pageSubtitle">
    <logic:notEqual name="csSearchResultView" property="searchResultMsg" value="ShowResults"> 
     <span class="left"><bean:message bundle="cm.messages" key="cm.content.searchCriteria"/></span>
    </logic:notEqual>
    <logic:equal name="csSearchResultView" property="searchResultMsg" value="ShowResults"> 
     <span class="left"><bean:message bundle="cm.messages" key="cm.content.search.searchResultFound" arg0="<%= totalCount.toString() %>" /></span> 
    </logic:equal> 
    <span class="right">
   <input type="button" name="results" class="inputButton"  onClick="return onSubmit(this.form, 'cmCSSearchForm')"
                value="<bean:message bundle="cm.messages" key="button.showResults"/>">
    </span>
    <span class="right">&nbsp;</span>
  </div> 

  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle="cm.messages" key="cm.content.advSearch"/>">
         
  <!--start main content here-->
 
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.contentName"/>: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="contentName" maxlength="80" size="31" />
      </td>
    </tr>

    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.attributes"/>: </td>
      <td valign="top" class="labelField" width="80%" colspan="2" nowrap>
      <html:select name ="csSearchResultView" property="attributes1a" size="1">
        <html:option value=""></html:option>
        <html:option value="CreatedBy"><bean:message bundle="cm.messages" key="cm.content.author"/></html:option>
        <html:option value="CheckedOutBy"><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></html:option>
        <html:option value="DocumentType"><bean:message bundle="cm.messages" key="cm.content.doctype"/></html:option>
        <html:option value="VersionCreatedBy"><bean:message bundle="cm.messages" key="cm.content.modifiedBy"/></html:option>
        <html:option value="VersionNumber"><bean:message bundle="cm.messages" key="cm.content.version"/></html:option>
      </html:select>
      <html:select name ="csSearchResultView" property="attributes1b" size="1">
        <html:option value="-1">&nbsp;</html:option>
        <html:option value="0"><bean:message bundle="cm.messages" key="cm.content.eq"/></html:option>
        <html:option value="1"><bean:message bundle="cm.messages" key="cm.content.neq"/></html:option>
        <html:option value="2"><bean:message bundle="cm.messages" key="cm.content.lt"/></html:option>
        <html:option value="3"><bean:message bundle="cm.messages" key="cm.content.lteq"/></html:option>
        <html:option value="4"><bean:message bundle="cm.messages" key="cm.content.gt"/></html:option>
        <html:option value="5"><bean:message bundle="cm.messages" key="cm.content.gteq"/></html:option>
      </html:select>
      <html:text name="csSearchResultView" property="attributes1c" maxlength="80" size="31" />&nbsp; <bean:message bundle="cm.messages" key="cm.content.and"/>
    </tr>

    <tr>
      <td valign="top" width="20%" class="label">&nbsp;</td>
      <td valign="top" class="labelField" width="80%" colspan="2" nowrap>
      <html:select name ="csSearchResultView" property="attributes2a" size="1">
        <html:option value=""></html:option>
        <html:option value="CreatedBy"><bean:message bundle="cm.messages" key="cm.content.author"/></html:option>
        <html:option value="CheckedOutBy"><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></html:option>
        <html:option value="DocumentType"><bean:message bundle="cm.messages" key="cm.content.doctype"/></html:option>
        <html:option value="VersionCreatedBy"><bean:message bundle="cm.messages" key="cm.content.modifiedBy"/></html:option>
        <html:option value="VersionNumber"><bean:message bundle="cm.messages" key="cm.content.version"/></html:option>
      </html:select>
      <html:select name ="csSearchResultView" property="attributes2b" size="1">
        <html:option value="-1">&nbsp;</html:option>
        <html:option value="0"><bean:message bundle="cm.messages" key="cm.content.eq"/></html:option>
        <html:option value="1"><bean:message bundle="cm.messages" key="cm.content.neq"/></html:option>
        <html:option value="2"><bean:message bundle="cm.messages" key="cm.content.lt"/></html:option>
        <html:option value="3"><bean:message bundle="cm.messages" key="cm.content.lteq"/></html:option>
        <html:option value="4"><bean:message bundle="cm.messages" key="cm.content.gt"/></html:option>
        <html:option value="5"><bean:message bundle="cm.messages" key="cm.content.gteq"/></html:option>
      </html:select>
      <html:text name="csSearchResultView" property="attributes2c" maxlength="80" size="31" />&nbsp; <bean:message bundle="cm.messages" key="cm.content.and"/>

    <tr>
      <td valign="top" width="20%" class="label">&nbsp;</td>
      <td valign="top" class="labelField" width="80%" colspan="2" nowrap>
      <html:select name ="csSearchResultView" property="attributes3a" size="1">
        <html:option value=""></html:option>
        <html:option value="CreatedBy"><bean:message bundle="cm.messages" key="cm.content.author"/></html:option>
        <html:option value="CheckedOutBy"><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></html:option>
        <html:option value="DocumentType"><bean:message bundle="cm.messages" key="cm.content.doctype"/></html:option>
        <html:option value="VersionCreatedBy"><bean:message bundle="cm.messages" key="cm.content.modifiedBy"/></html:option>
        <html:option value="VersionNumber"><bean:message bundle="cm.messages" key="cm.content.version"/></html:option>
      </html:select>
      <html:select name ="csSearchResultView" property="attributes3b" size="1">
        <html:option value="-1">&nbsp;</html:option>
        <html:option value="0"><bean:message bundle="cm.messages" key="cm.content.eq"/></html:option>
        <html:option value="1"><bean:message bundle="cm.messages" key="cm.content.neq"/></html:option>
        <html:option value="2"><bean:message bundle="cm.messages" key="cm.content.lt"/></html:option>
        <html:option value="3"><bean:message bundle="cm.messages" key="cm.content.lteq"/></html:option>
        <html:option value="4"><bean:message bundle="cm.messages" key="cm.content.gt"/></html:option>
        <html:option value="5"><bean:message bundle="cm.messages" key="cm.content.gteq"/></html:option>
      </html:select>
      <html:text name="csSearchResultView" property="attributes3c" maxlength="80" size="31" />&nbsp; <bean:message bundle="cm.messages" key="cm.content.and"/>
    </tr>

    <tr>
      <td valign="top" width="20%" class="label">&nbsp;</td>
      <td valign="top" class="labelField" width="80%" colspan="2" nowrap>
      <html:select name ="csSearchResultView" property="attributes4a" size="1">
        <html:option value=""></html:option>
        <html:option value="CreatedBy"><bean:message bundle="cm.messages" key="cm.content.author"/></html:option>
        <html:option value="CheckedOutBy"><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></html:option>
        <html:option value="DocumentType"><bean:message bundle="cm.messages" key="cm.content.doctype"/></html:option>
        <html:option value="VersionCreatedBy"><bean:message bundle="cm.messages" key="cm.content.modifiedBy"/></html:option>
        <html:option value="VersionNumber"><bean:message bundle="cm.messages" key="cm.content.version"/></html:option>
      </html:select>
      <html:select name ="csSearchResultView" property="attributes4b" size="1">
        <html:option value="-1">&nbsp;</html:option>
        <html:option value="0"><bean:message bundle="cm.messages" key="cm.content.eq"/></html:option>
        <html:option value="1"><bean:message bundle="cm.messages" key="cm.content.neq"/></html:option>
        <html:option value="2"><bean:message bundle="cm.messages" key="cm.content.lt"/></html:option>
        <html:option value="3"><bean:message bundle="cm.messages" key="cm.content.lteq"/></html:option>
        <html:option value="4"><bean:message bundle="cm.messages" key="cm.content.gt"/></html:option>
        <html:option value="5"><bean:message bundle="cm.messages" key="cm.content.gteq"/></html:option>
      </html:select>
      <html:text name="csSearchResultView" property="attributes4c" maxlength="80" size="31" />&nbsp;
    </tr>
    
    <tr>
      <td valign="middle" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.contentCreationDate"/>:</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeCreateDateStart"/>
        <bean:message bundle="cm.messages" key="cm.content.from"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="createDateStart"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','createDateStart')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" width="20%" class="label">&nbsp;</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeCreateDateEnd"/>
        <bean:message bundle="cm.messages" key="cm.content.to"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="createDateEnd"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','createDateEnd')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.contentModificationDate"/>:</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeModDateStart"/>
        <bean:message bundle="cm.messages" key="cm.content.from"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="modDateStart"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','modDateStart')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" width="20%" class="label">&nbsp;</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeModDateEnd"/>
        <bean:message bundle="cm.messages" key="cm.content.to"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="modDateEnd"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','modDateEnd')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
        
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.processModelName"/>: </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procModelName" maxlength="80" size="31" />
      </td>
    </tr>
    <tr>
      <td valign="top" width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.search.curversion"/> </td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html-el:radio property="curVersion" value="1" /><bean:message bundle='cm.messages' key='cm.content.search.yes'/>&nbsp;<html-el:radio property="curVersion" value="0" /><bean:message bundle='cm.messages' key='cm.content.search.no' />
      </td>
    </tr>
    
    <tr>
      <td valign="top" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.processManager"/></td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procMgrID" maxlength="80" size="31" />
             <input type="button" name="browseUsers" class="pageButton" 
            onClick="JavaScript:findUserPopup('/bvmc/mt/userSearchPopup.do', 'cmCSSearchForm', 'procMgrID')"
                    value='<bean:message bundle='cm.messages' key="button.browse"/>'>
      </td>
    </tr>
    <tr>
      <td valign="top" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.instanceManager"/></td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procInstMgrID" maxlength="80" size="31" />
          <input type="button" name="browseUsers" class="pageButton"
            onClick="JavaScript:findUserPopup('/bvmc/mt/userSearchPopup.do', 'cmCSSearchForm', 'procInstMgrID')"
            value='<bean:message bundle="cm.messages" key="button.browse"/>'>
      </td>
    </tr>
    <tr>
      <td valign="top" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.launchUser"/></td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procInitiatorID" maxlength="80" size="31" />
          <input type="button" name="browseUsers" class="pageButton"
            onClick="JavaScript:findUserPopup('/bvmc/mt/userSearchPopup.do', 'cmCSSearchForm', 'procInitiatorID')"
            value='<bean:message bundle="cm.messages" key="button.browse"/>'>
      </td>
    </tr>

    <tr>
      <td valign="top" wrap width="20%" class="label"> <bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.participant"/></td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procInstParticipantID" maxlength="80" size="31" />
          <input type="button" name="browseUsers" class="pageButton"
            onClick="JavaScript:findUserPopup('/bvmc/mt/userSearchPopup.do', 'cmCSSearchForm', 'procInstParticipantID')"
            value='<bean:message bundle="cm.messages" key="button.browse"/>'>
      </td>
    </tr>
    
    <tr>
      <td valign="top" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.processInstanceName"/>:</td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:text name="csSearchResultView" property="procInstanceName" maxlength="80" size="31" />
      </td>
    </tr>

    <tr>
      <td valign="middle" width="20%" class="label">&nbsp;</td>
      <td valign="middle" width="80%" class="labelField" colspan="2"><input type="button" name="overdue" class="inputButton"  onClick="selectOverdue(this.form);"
        value="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.overdue"/>">
      </td>	
    </tr>    
        
   <tr>
     <td valign="top" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.status"/></td>
     <td valign="top" class="labelField" width="80%" colspan="2">
                
     <%
      ProcessList pl = (ProcessList)session.getAttribute("com.broadvision.process.tools.action.process.ProcessList");
      String[] states = pl.getProcessInstanceStatesAsArray();
     %>

     <logic:iterate name="com.broadvision.process.tools.action.process.ProcessList" property="processInstanceStateValues" id="stateValue" indexId="i">
  <logic:lessThan name="stateValue" value="2">
       <html:multibox name="csSearchResultView" property="sspInstanceStatus" >
         <bean:write name="stateValue" />
       </html:multibox>
       <%= states[i.intValue()] %>
  </logic:lessThan>
     </logic:iterate>
     </td>
   </tr>

   <tr>
      <td valign="middle" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.processBeginDate"/>:</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeLaunchDateStart"/>
        <bean:message bundle="cm.messages" key="cm.content.from"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="launchDateStart"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','launchDateStart')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" width="20%" class="label">&nbsp;</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeLaunchDateEnd"/>
        <bean:message bundle="cm.messages" key="cm.content.to"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="launchDateEnd"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','launchDateEnd')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" wrap width="20%" class="label"><bean:message bundle="cm.messages" key="cm.content.processDueDate"/>:</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeDueDateStart"/>
        <bean:message bundle="cm.messages" key="cm.content.from"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="dueDateStart"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','dueDateStart')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>
  
    <tr>
      <td valign="middle" width="20%" class="label">&nbsp;</td>
      <td valign="middle" width="10%" class="labelField" nowrap>  	      
        <html:checkbox property="includeDueDateEnd"/>
        <bean:message bundle="cm.messages" key="cm.content.to"/>:
      </td>
      <td valign="middle" width="70%" class="labelField" nowrap>	
        <bvhtml:date name="csSearchResultView" property="dueDateEnd"
          onChangeMonth="onChangeMonth" onChangeYear="onChangeYear"/>
        <a href="JavaScript:datePopup(
          '<html:rewrite page="/cm/calendar.do"/>', 'cmCSSearchForm','dueDateEnd')">
          <img src="<%= ctxPath %>/mc/images/action/calendar.gif" width="22" height="22" 
            alt="<bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.chooseDate" />" 
            border="0" align="absmiddle"/>
        </a>				  
      </td>
    </tr>

    <tr> 
      <td valign="top" width="20%" class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.sortby"/></td>
      <td valign="top" class="labelField" width="80%" colspan="2">
        <html:select name ="csSearchResultView" property="sortBy" size="1">
        <html:option value=""><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.option.nosort"/></html:option>
        <html:option value="contentName"><bean:message bundle="cm.messages" key="cm.content.contentName"/></html:option>
        <html:option value="version"><bean:message bundle="cm.messages" key="cm.content.version"/></html:option>
        <html:option value="contentObjectType"><bean:message bundle="cm.messages" key="cm.content.type"/></html:option>
        <html:option value="versionCreatedTime"><bean:message bundle="cm.messages" key="cm.content.modifiedOn"/></html:option>
        <html:option value="checkedOutBy"><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></html:option>
        <html:option value="processInstanceName"><bean:message bundle="cm.messages" key="cm.content.processInstanceName"/></html:option>
        </html:select>
        &nbsp; &nbsp;<span class="label"><bean:message bundle="cm.messages" key="cm.process.processInstanceSearch.rows"/></span>
        <html:select name ="csSearchResultView" property="limitPerPage" size="1" >
        <html:option value="10">10</html:option>
        <html:option value="20">20</html:option>
        <html:option value="30">30</html:option>
        <html:option value="50">50</html:option>
        <html:option value="100">100</html:option>
        </html:select>
      </td>
    </tr>
        
  </table>
  <div class="pageButtonWrap" align="right">
   <input type="button" name="results" class="inputButton"  onClick="return onSubmit(this.form, 'cmCSSearchForm')"
                value="<bean:message bundle="cm.messages" key="button.showResults"/>">
  </div>  
      
  <br>
	  
<logic:match name="csSearchResultView" property="searchResultMsg" value="ShowResults">

  <div class="pageSubtitle">
    <span class="left"><bean:message bundle="cm.messages" key="cm.content.search.searchResultFound" arg0="<%= totalCount.toString() %>" /></span>
    <span class="right">&nbsp;</span>
  </div>
    
  <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle="cm.messages" key="cm.content.searchResultList"/>">
  <tr class="listHeader"> 
    <th id="Content Name" align="left"><bean:message bundle="cm.messages" key="cm.content.contentName"/></th>
    <th id="Version" align="left"><bean:message bundle="cm.messages" key="cm.content.version"/></th>
    <th id="Type" align="left" nowrap><bean:message bundle="cm.messages" key="cm.content.type"/></th>
    <th id="Modified on" align="left" nowrap><bean:message bundle="cm.messages" key="cm.content.modifiedOn"/></th>
    <th id="Modified by" align="left" nowrap><bean:message bundle="cm.messages" key="cm.content.modifiedBy"/></th>
    <th id="Checked out by" align="left" nowrap><bean:message bundle="cm.messages" key="cm.content.checkedOutBy"/></th>
    <th id="Process Instance" align="left" nowrap><bean:message bundle="cm.messages" key="cm.content.processInstance"/></th>
    <th id="Action" align="left"><bean:message bundle='cm.messages' key='cm.browse.actions'/></th>
  </tr>     
  
  <logic:equal name="resultSize" value="0">
  <tr class="listEven"> 
    <td colspan="8" valign="top" align="center"><bean:message bundle="cm.messages" key="cm.content.noContentFound"/></td>
  </tr>
  </logic:equal>

  <logic:iterate id="result" name="csSearchResultView" property="resultList" indexId="index">  
    <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
      <td headers="Content Name" align="left">
      <logic:equal name="result" property="attachment" value="false">    
      <a href="JavaScript:doWebflowAction(document.cmCSSearchForm,'<c:out value="${result.map.oid}"/>','<c:out value="${result.map.version}"/>','View')" >
         <bean:write name="result" property="contentName"/>
      </a>
      </logic:equal>
      <logic:equal name="result" property="attachment" value="true"> 
       <a href="#" onclick='javascript:doAttachment(document.cmCSSearchForm,"<bean:write name='result' property='urlParams'/>")'> <bean:write name="result" property="contentName"/></a>
      </logic:equal>          
      </td>
      <td headers="Version"><bean:write name="result" property="version"/></td>
      <td headers="Type" align="center"><bean:write name="result" property="contentObjectType"/></td>
      <td headers="Modified on"><bean:write name="result" property="versionCreatedTime" formatKey="format.datetime.long" bundle="cm.messages"/></td>
      <td headers="Modified by"><bean:write name="result" property="versionCreatedBy"/></td>
      <td headers="Checked out by" align="center"><bean:write name="result" property="checkedOutBy"/></td>
      <td headers="Process Instance" align="center">
      <html:link page="/cm/processInstance.do?" name="result" property="procUrlParams">
        <bean:write name="result" property="processInstanceName"/>
      </html:link>
      </td>
   <td headers="Action" align="left" nowrap>
<c:if test="${result.map.contentObjectType == 'BV_XML'}">
      <a href="JavaScript:doWebflowAction(document.cmCSSearchForm,'<c:out value="${result.map.oid}"/>','<c:out value="${result.map.version}"/>','View')" >
      <img src="<%=ctxPath%>/mc/images/action/icon_view.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.view"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.view"/>'></a>
      <a href="JavaScript:doWebflowAction(document.cmCSSearchForm,'<c:out value="${result.map.oid}"/>','<c:out value="${result.map.version}"/>','Edit')" >
      <img src="<%=ctxPath%>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.edit"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.edit"/>'></a>
      <a href="JavaScript:doAction(document.cmCSSearchForm,'<c:out value="${result.map.oid}"/>','<c:out value="${result.map.version}"/>','Review')" >
      <img src="<%=ctxPath%>/mc/images/action/icon_launch.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.launch"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.launch"/>'></a>
      <c:if test="${cmContentAdmin == 'true'}">
      <a href="JavaScript:doUncheckout(document.cmCSSearchForm, '<c:out value="${result.map.oid}"/>')">
      <img src="<%=ctxPath%>/mc/images/action/icon_uncheckout.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.uncheckout"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.uncheckout"/>'></a> 
      </c:if>
      <a href="JavaScript:doWebflowAction(document.cmCSSearchForm,'<c:out value="${result.map.oid}"/>','<c:out value="${result.map.version}"/>','Delete')" >
      <img src="<%=ctxPath%>/mc/images/action/icon_delete.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean-el:message bundle="cm.messages" key="image.alt.delete"/>' title='<bean-el:message bundle="cm.messages" key="image.alt.delete"/>'></a>
</c:if>
      </td>
    </tr>
  </logic:iterate>
  </table>

</logic:match>


<c:if test="${csSearchResultView.map.pagination == '1'}">
   
  <div class="pagination">
    <bean:message key="cm.common.pagination.show" bundle="cm.messages"/>
      <html:select property="entriesPerPage" size="1" onchange="doGoCnt('cmCSSearchForm')">
        <html:option value="10">10</html:option>
        <html:option value="20">20</html:option>
        <html:option value="30">30</html:option>
        <html:option value="50">50</html:option>
        <html:option value="100">100</html:option>
      </html:select>
      <bean:message key="cm.common.pagination.itemsPerPage" bundle="cm.messages"/>
      &nbsp;&nbsp; 
   <% 
     Integer currentPageNumberInt = (Integer) PropertyUtils.getSimpleProperty(view, "currPageNum"); 
     Integer totalPageNumberInt = (Integer) PropertyUtils.getSimpleProperty(view, "totalPageNum"); 
   %>
   

 <c:if test="${csSearchResultView.map.currPageNum >1}">  
    <a href="#" class="paginationBtn" onclick="javascript:gotoPage('cmCSSearchForm', 1)"><bean:message bundle='cm.messages' key='cm.common.pagination.first'/></a>
    <a href="#" class="paginationBtn" onclick="javascript:gotoPage('cmCSSearchForm', <%= currentPageNumberInt.intValue()-1 %>)"><bean:message bundle='cm.messages' key='cm.common.pagination.previous'/></a>
  </c:if>

  <bean:message bundle='cm.messages' key='cm.common.pagination.pageOf' arg0="<%= currentPageNumberInt.toString() %>" arg1="<%= totalPageNumberInt.toString() %>"/>

 <c:if test="${csSearchResultView.map.currPageNum < csSearchResultView.map.totalPageNum}">  
    <a href="#" class="paginationBtn" onclick="javascript:gotoPage('cmCSSearchForm', <%= currentPageNumberInt.intValue()+1 %>)"><bean:message bundle='cm.messages' key='cm.common.pagination.next'/></a>
    <a href="#" class="paginationBtn" onclick="javascript:gotoPage('cmCSSearchForm', <%= totalPageNumberInt.intValue() %>)"><bean:message bundle='cm.messages' key='cm.common.pagination.last'/></a>
  </c:if>
 </div>
</c:if>
 </td>
 </tr>

</table>
</html:form>
